// pages/login/phone_enrol/phone_enrol.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    phone:"",//输入的手机号
    pwdtip:false,//密码提示
    pwd:"",//密码
  },
  //验证手机合法性
  phoneBlur(e){
    let that = this;
    let regExp = new RegExp("0?(13|14|15|18|17)[0-9]{9}")//验证手机号是否合法
    that.setData({
      phone: e.detail.value
    })
    if(!regExp.test(that.data.phone)){
      wx.showToast({
        title: "手机号码格式不对",
        icon: 'none',
        duration: 1500,
        mask: false,
      });
      setTimeout(function(){
        that.setData({
          phone:''
        })
      },1500)
    }
  },
  //获取验证码
  onclick(){
    wx.showToast({
      title: "暂无数据",
      icon: 'none',
      duration: 500,
      mask: false,
    });
  },
  //密码聚焦时提示
  onfocus(){
    let that = this;
    that.setData({
      pwdtip:"true"
    })
  },
  //密码失去焦点
  pwdblur(e){
    let that = this;
    let regExp = new RegExp("^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$");
    that.setData({
      pwd:e.detail.value
    });
    if(!regExp.test(that.data.pwd)){
      wx.showToast({
        title: "密码错误",
        icon: 'none',
        duration: 1500,
        mask: false,
      });
      that.setData({
        pwd:""
      })
    }else{
      that.setData({
        pwdtip:false,
      })
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
  },
  onTip(){
    console.log(111)
    let that = this;
    if(that.data.phone!=''&&that.data.pwd!=''){
      wx.showToast({
        title: "注册成功",
        icon: 'none',
        duration: 1500,
        mask: false,
      });
      wx.navigateTo({
        url: "/pages/login/login_phone/login_phone"
      });
    }else{
      wx.showToast({
        title: "注册失败请核对信息",
        icon: 'none',
        duration: 1500,
        mask: false,
      });
    }
  }
  
})